package com.soft.util;

public class CheckUnicode
{

	public CheckUnicode()
	{
	}

	public static java.lang.String CheckUnicodeString(java.lang.String value)
	{
		if (CheckUnicode.hasLuanMa(value))
			return CheckUnicode.makeUpString(value);
		else
			return value;
	}

	private static boolean hasLuanMa(java.lang.String value)
	{
		boolean hasLuanMa = false;
		if (null != value && value.length() > 0)
		{
			int i = 0;
			do
			{
				if (i >= value.length())
					break;
				char ch = value.charAt(i);
				if (ch > '\uFFFD' || ch < ' ' && ch != '\t' && ch != '\n' && ch != '\r')
				{
					hasLuanMa = true;
					break;
				}
				i++;
			} while (true);
			return hasLuanMa;
		} else
		{
			return false;
		}
	}

	private static java.lang.String makeUpString(java.lang.String value)
	{
		java.lang.StringBuilder sb = new StringBuilder();
		if (null != value && value.length() > 0)
		{
			for (int i = 0; i < value.length(); i++)
			{
				char ch = value.charAt(i);
				if (ch <= '\uFFFD' && (ch >= ' ' || ch == '\t' || ch == '\n' || ch == '\r'))
					sb.append(ch);
			}

		}
		java.lang.String result = sb.toString();
		return sb.toString();
	}
}
